import com.google.gson.Gson;

public class jsonStr {
    //"{"age":22,"clazz":"文科六班","gender":"女","id":"1500100001","name":"发大厦"}"
    public static void main(String[] args) {
        String josnstr="{\"age\":22,\"clazz\":\"文科六班\",\"gender\":\"女\",\"id\":\"1500100001\",\"name\":\"发大厦\"}";
//        System.out.println(josnstr);
        //通过Gson解析json字符串  转化为对象
        Gson gson = new Gson();
        Student student = gson.fromJson(josnstr, Student.class);
        System.out.println(student.getName());
        System.out.println(student.getSex());
        //把对象转化为字符串
        Student student1 = new Student("1001", "zs", "26", "一班", "男");
        String s = gson.toJson(student1);
        System.out.println(s);
    }
}
